'''
添加合同页
'''
from selenium.webdriver.common.by import By
from page.base_page import BasePage

class AddHtPage(BasePage):
    url="/crm/index.php?m=contract&a=add"

    #定位器
    sj_origin_locator = (By.NAME, "business_name")
    sj_origin_select_locator = (By.CSS_SELECTOR, "#data > tr:nth-child(1) > td:nth-child(1) > input[type=radio]:nth-child(1)")
    sj_origin_select_ok_locator = (By.CSS_SELECTOR, "body > div:nth-child(12) > div.ui-dialog-buttonpane.ui-widget-content.ui-"
                     "helper-clearfix > div > button:nth-child(1)")
    save_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div > form > table > thead > tr > "
                                     "td:nth-child(2) > input.btn.btn-primary")
    ht_number_locator=(By.CSS_SELECTOR,"#number")
    def click_sj_origin(self):
        '''点击商机来源输入框'''
        self.driver.find_element(*self.sj_origin_locator).click()
    def click_sj_origin_select(self):
        '''点击弹窗的第一个'''
        self.driver.find_element(*self.sj_origin_select_locator).click()
    def click_sj_origin_select_ok(self):
        self.driver.find_element(*self.sj_origin_select_ok_locator).click()

    def click_save(self):
        '''点击保存'''
        self.driver.find_element(*self.save_locator).click()
    def get_ht_number(self):
        '''获取合同编号'''
        return self.driver.find_element(*self.ht_number_locator).get_attribute("value").strip()
